import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getx_demo/controller/countController.dart';

class ListPage extends StatefulWidget {
  const ListPage({super.key});

  @override
  State<ListPage> createState() => _ListPageState();
}

class _ListPageState extends State<ListPage> {
  final CountController _countcontroller = Get.find();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text("列表页"),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              const Text('列表页'),
              const SizedBox(height: 20),
              // Obx(() => Text(_countcontroller.count.toString())),
              GetBuilder<CountController>(
                builder: (controller) => Text("计数：${controller.count}"),
              ),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () {
                  _countcontroller.increase();
                },
                child: const Text('修改值'),
              ),
              const SizedBox(height: 20),
              // 接收参数
              Text(Get.arguments?['name'] ?? '无参数'),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () {
                  Get.back();
                },
                child: const Text('返回首页'),
              )
            ],
          ),
        ));
  }
}
